import { reqUserOrderList, reqUserAddress } from '@/api'
const state = {
    userAddress: [],
    userOrder: {}
}

const mutations = {
    GETUSERADDRESS(state, userAddress) {
        state.userAddress = userAddress
    },
    GETUSERORDER(state, userOrder) {
        state.userOrder = userOrder
    },
}

const actions = {
    async getUserAddress({ commit }) {
        const res = await reqUserAddress()
        console.log(res)
        if (res.code === 200) {
            commit('GETUSERADDRESS', res.data)
        }
    },
    async getUserOrder({ commit }) {
        const res = await reqUserOrderList()
        console.log(res)
        if (res.code === 200) {
            commit('GETUSERORDER', res.data)
        }
    }
}

const getters = {

}

export default {
    state,
    mutations,
    actions,
    getters,
}